﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;
using digitwhu.Models;
using digitwhu.Models.IRepositorys;
namespace digitwhu.Models.Repositorys
{
    public class ManageFriendsRepository:Repository<Attention>,IManageFriendsRepository
    {
        public ManageFriendsRepository(DataContext dc)
            : base(dc)
        {
        }
        public  bool GetUserIsUserAttention(int from, int to)//判断用户from是否已经关注用户to
        {                  
            //from:主动关注的用户编号
            //to:被关注的用户编号
            //返回值：true：用户from已经关注to，false：用户from未关注好友to
            Func<Attention, bool> expr = c => c.userPayAttention == from && c.userBeFocused == to;
            if (context.GetTable<Attention>().Where(expr).Count() > 0)
                return true;
            else
                return false;
        }

    }
}